<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title>订单列表-WeAdmin Frame型后台管理系统-WeAdmin 1.0</title>
		<meta name="renderer" content="webkit">
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
		<link rel="stylesheet" href="../../static/css/font.css">
		<link rel="stylesheet" href="../../static/css/weadmin.css">
		<link rel="stylesheet" href="https://unpkg.com/element-ui@2.13.1/lib/theme-chalk/index.css">
		<script src="../../lib/layui/layui.js" charset="utf-8"></script>
		<!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
		<!--[if lt IE 9]>
	      <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
	      <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
	    <![endif]-->
		<script src="../../../../assets/js/vendor/vue.min.js"></script>
		<script src="../../../../assets/js/vendor/jquery-3.3.1.min.js"></script>
		<script src="../../../../assets/js/plugins/utils.js"></script>
		<script src="https://unpkg.com/element-ui@2.13.1/lib/index.js"></script>
	</head>

	<body>
		<div class="weadmin-nav">
			<span class="layui-breadcrumb">
        <a href="">首页</a>
        <a href="">订单管理</a>
        <a><cite>订单列表</cite></a>
      </span>
			<a class="layui-btn layui-btn-sm" style="line-height:1.6em;margin-top:3px;float:right" href="javascript:location.replace(location.href);" title="刷新">
				<i class="layui-icon" style="line-height:30px">ဂ</i></a>
		</div>
		<div class="weadmin-body" id="orderItem">
			<div class="layui-row">
				<div class="layui-form layui-col-md12 we-search">
					<div class="layui-inline">
						<input class="layui-input" placeholder="开始日" name="start" id="start">
					</div>
					<div class="layui-inline">
						<input class="layui-input" placeholder="截止日" name="end" id="end">
					</div>
					<div class="layui-inline">
						<input type="text" name="sid" id="sid" placeholder="请输入订单号" autocomplete="off" class="layui-input">
					</div>
					<button class="layui-btn" @click="search()"><i class="layui-icon">&#xe615;</i></button>
				</div>
			</div>
			<div class="weadmin-block">
				<span class="fr" style="line-height:40px">共有数据：{{page.total}} 条</span>
			</div>
			<table class="layui-table">
				<thead>
					<tr>
						<th>订单编号</th>
						<th>收货人</th>
						<th>总金额</th>
						<th>应付金额</th>
						<th>发货状态</th>
						<th>支付方式</th>
						<th>下单时间</th>
						<th>操作</th>
					</tr>
				</thead>
				<tbody>
					<tr v-for="(order,index) in orderList"  v-if="orderList!=''">
						<td>{{order.sid}}</td>
						<td>{{order.consignee}}</td>
						<td>{{order.old_price}}</td>
						<td>{{order.new_price}}</td>
						<td>{{order.status}}</td>
						<td>其他方式</td>
						<td>{{order.time}}</td>
						<td class="td-manage">
							<a title="编辑" @click="show(order.id)" href="javascript:;">
								<i class="layui-icon layui-icon-edit"></i>
							</a>
							<a title="删除" @click="deleteOrder(order.id)" href="javascript:;">
								<i class="layui-icon">&#xe640;</i>
							</a>
						</td>
					</tr>
				</tbody>
			</table>
			<div class="block">
				<el-pagination
						@current-change="handleCurrentChange"
						:current-page.sync="page.pageNum"
						:page-size="page.pageSize"
						:hide-on-single-page="true"
						layout="total, prev, pager, next"
						:total="page.pages">
				</el-pagination>
			</div>

		</div>
		<script src="../../lib/layui/layui.js" charset="utf-8"></script>
		<script src="../../static/js/eleDel.js" type="text/javascript" charset="utf-8"></script>
		<script type="text/javascript">
			var order_list = new Vue({
				el: "#orderItem",
				data: {
					orderList: [],
					page: {"pageNum": 1, "pageSize": 10, "pages": 0, "total": 0}
				},
				mounted: function () {
					this.getOrderList();
				},
				methods: {
					getOrderList() {
						$.ajax({
							url: "/admin/order_list/"+this.page.pageNum,
							type: "GET",
							headers: {
								"Authorization": "Bearer " + handleLocalStorage("get", "token")
							},
							success: function (response) {
								if (response.code == 200) {
									order_list.orderList=response.data.list;
									order_list.page.pageNum = response.data.pageNum;
									order_list.page.pageSize = response.data.pageSize;
									order_list.page.pages = response.data.pages;
									order_list.page.total = response.data.total;
								}else {
								}
							},
							error: function (error) {
								alert("服务器错误");
							}

						});
					},
					deleteOrder(id) {
						var t = this;
						$.ajax({
							url: "/admin/order_delete/"+id,
							type: "GET",
							headers: {
								"Authorization": "Bearer " + handleLocalStorage("get", "token")
							},
							success: function (response) {
								alert(response.message);
								if (response.code == 200) {
									order_list.getOrderList();
								}
							},
							error: function (error) {
								alert("服务器错误");
							}
						});
					},
					search() {
						this.page.pageNum = 1;
						var start = $("#start").val();
						var end = $("#end").val();
						var sid = $("#sid").val();
						$.ajax({
							url: "/admin/order_search?start="+start+"&end="+end+"&sid="+sid+"&pageNum=1",
							type: "GET",
							headers: {
								"Authorization": "Bearer " + handleLocalStorage("get", "token")
							},
							success: function (response) {
								if (response.code == 200) {
									order_list.orderList=response.data.list;
									order_list.page.pageNum = response.data.pageNum;
									order_list.page.pageSize = response.data.pageSize;
									order_list.page.pages = response.data.pages;
									order_list.page.total = response.data.total;
									console.log(response);
								}else {
								}
							},
							error: function (error) {
								alert("服务器错误");
							}

						});
					},
					handleCurrentChange(val) {
						this.page.pageNum = val;
						this.getOrderList();
					},
					show(id) {
						WeAdminEdit('编辑','./edit.html?id='+id, 2, 600, 400);
					}
				}
			});
		</script>
	</body>

</html>